<?php

namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Brick\Math\RoundingMode;

class AppleTreeRecordsResource extends JsonResource
{
    public function toArray($request)
    {
    	$data = $this->resource;
    	
        return [
	        'id' 				=> (int)$data->id,
	        'user_id' 			=> (int)$data->user_id,
	        'title'    => $data->appleTree->title,
	        'dividend_money' => $data->dividend_money,
	        'produce_apples' => (string)big_decimal($data->appleTree->produce_apples)->dividedBy(30 ,2 , RoundingMode::HALF_UP),
	        'expired_at' => (string)$data->expired_at,
	        'image' =>img_path($data->appleTree->image)
        ];
    }
}
